import initServerInstance from '../server/initServerInstance';

if (require.main === module) {
	(async () => {
		const server = await initServerInstance({
			loggerConfig: {
				name: 'upgrade',
				alwaysCreate: true,
			},
		});

		for await (const record of server.app.model.Job.find()) {
			record.target.port = record.target.protocol === 'http:' ? 80 : 443;
			await record
				.save()
				.catch(error => server.log.error({ error, record }, '保存失败'));
		}

		process.exit();
	})();
}
